package com.kayden.mybatis.service;


import com.kayden.mybatis.mapper.UserInfoMapper;
import com.kayden.mybatis.model.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {

    @Autowired
    private UserInfoMapper userInfoMapper;


    public List<UserInfo> getAllUser(){
        return userInfoMapper.selectAll();
    }

    public UserInfo getUserInfoById(Integer id){
        return userInfoMapper.selectAllById(id);
    }

    public UserInfo queryUserByUserNameAndPassword(String userName, String password) {
        List<UserInfo> userInfos = userInfoMapper.selectByNameAndPassword(password,userName);
        if (userInfos != null && userInfos.size() >=1) {
            return userInfos.get(0);
        }
        return null;
    }
}
